package com.wll.thread.concurrent.ch01.newCached;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.wll.thread.concurrent.base.LiftOff;

public class TestNewCache {
	public static void main(String[] args) {
		// CachedThreadPool可以为每一个任务分配一个线程
		// CachedThreadPool在程序执行过程中通常会创建与所需数量相同的线程
		// 然后在它回收旧线程时停止创建新线程，因此它是合理的Executor的首选
		ExecutorService exec = Executors.newCachedThreadPool();
		for (int i = 0; i < 5; i++) {
			exec.execute(new LiftOff());
		}
		exec.shutdown();
	}
}
